using UnityEngine;

public class BallInPocket : MonoBehaviour
{
	private Rigidbody m_Ball;

	private Vector3 m_RefPoint;

	private Transform m_Trans;

	private Vector2 m_Tempa;

	private Vector2 m_Tempb;

	private void Start()
	{
		m_Ball = GetComponent<Rigidbody>();
		m_Trans = base.transform;
	}

	public void FixedUpdate()
	{
		Vector3 normalized = (m_RefPoint - m_Trans.position).normalized;
		Vector3 normalized2 = m_Ball.velocity.normalized;
		m_Tempa = new Vector2(normalized.x, normalized.z);
		m_Tempb = new Vector2(normalized2.x, normalized2.z);
		if (!(Vector2.Dot(m_Tempa, m_Tempb) > 0.9f))
		{
			m_Ball.velocity = (normalized + normalized2).normalized * m_Ball.velocity.magnitude;
		}
	}

	private void OnDisable()
	{
		UnityEngine.Object.Destroy(this);
	}

	public void SetRefTrans(Transform refTrans)
	{
		m_RefPoint = refTrans.position;
	}
}
